package com.itheima.chapter08.set.map.treemap;

import java.util.Set;
import java.util.TreeMap;

//创建TreeMap集合，按照年龄进行排序，如果年龄相同，按照姓名排序
public class TreeMapdemo1 {
    public static void main(String[] args) {
        TreeMap<Student,String> tm =new TreeMap<Student, String>();
        Student s1=new Student("zhangsan",23);
        Student s2=new Student("lisi",33);
        Student s3=new Student("wangwu",29);
        tm.put(s1,"北京");
        tm.put(s2,"西安");
        tm.put(s3,"上海");
        Set<Student> keySet = tm.keySet();
        for (Student key : keySet) {
            String value = tm.get(key);
            System.out.println(key +" "+value);
        }

        }

    }
